<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:blacklist:remove']"
        >删除</el-button>
      </el-col>
    </el-row>

    <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="异常编号" width="200" align="center" prop="exceptionId" />
      <el-table-column label="报错原因" align="center" prop="exceptionReason" />
      <el-table-column label="发生时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
   <el-table-column
            label="详细信息"
            align="center"
            width="160"
            class-name="small-padding fixed-width"
          >

      <template slot-scope="scope">
        <el-button
          size="mini"
          type="text"
          icon="el-icon-edit"
          @click="getInfo(scope.row.detailInfo)"
          v-hasPermi="['system:user:edit']"
        >查看</el-button>
      </template>
    </el-table-column>
    </el-table>

    <!-- 详细信息对话框 -->
    <el-dialog :visible.sync="open" width="80%" append-to-body>
        <span v-html="this.info"></span>
        <div slot="footer" class="dialog-footer"  style="width:100%;text-align:center">
          <el-button type="primary" @click="closeInfo">关闭</el-button>
      </div>
    </el-dialog>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listExceptionLog,delExceptionLog } from "@/api/monitor/exception";

export default {
  name: "Blacklist",
  dicts: ['sys_blacklist_reason'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 异常详情
      info:undefined,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询登录日志 */
    getList() {
      this.loading = true;
      listExceptionLog(this.queryParams).then( response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    getInfo(detailInfo) {
      this.open = true;
      this.info = detailInfo;
    },
    closeInfo() {
      this.open = false;
    },
    /** 多选框选中数据 */
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.exceptionId)
      this.multiple = !selection.length
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除选中的数据项？').then(function() {
        return delExceptionLog(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    }
  }
};
</script>

